ABC151 C - Welcome to AtCoder
https://atcoder.jp/contests/abc151/tasks/abc151_c
提出
WA
code: python
n, m = map(int, input().split())
ac = 0
wa = 0
problem = {}
for i in range(1, n+1):
problemi = False
for _ in range(m):
p, s = i for i in input().split()
if (s == "WA"):
if (problemint(p)):
pass
else:
wa += 1
else:
if (problemint(p)):
pass
else:
ac += 1
problemint(p) = True
print(ac, wa)
解答
code: python
n, m = map(int, input().split())
ps = list(map(str,input().split())) for _ in range(m)
res = "WA" * n
wa_count = 0 * n
wa = 0
ac = 0
for p, s in ps:
p = int(p) - 1
if s == "AC":
resp = "AC"
else:
if resp != "AC":
wa_countp += 1
for i in range(n):
if resi == "AC":
wa += wa_counti
ac += 1
print(ac, wa)
メモ
「高橋君のペナルティ数は、高橋君が AC を 1 回以上出した各問題において、初めて AC を出すまでに出した WA の数の総和です。」なので、ACしてなかったらWAの総数は含めなくて良い
{1: (literal), 2: (literal)...}となる状態管理は配列で十分
提出
code: python
from collections import defaultdict
n, m = map(int, input().split())
ps = list(map(str, input().split())) for _ in range(m)
answerd = set()
warned = defaultdict(int)
ac = 0
wa = 0
for i in ps:
p = i0
s = i1
if (p in answerd):
continue
else:
if (s == "WA"):
warnedp += 1
else:
ac += 1
answerd.add(p)
for i in answerd:
wa += warnedi
print(ac, wa)